package com.itheima.UDP.UDP发送协议;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

//UDP的发送
public class Clientdemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds=new DatagramSocket();
        //2.封装数据报包 --报文
        //要发送的字节数组，字节数组长度，要发给谁
        DatagramPacket dp=new DatagramPacket("   ".getBytes(),
                "   ".getBytes().length,
                InetAddress.getByName("192.168.18.61"),10086);
        //基于socket将数据发送出去
        ds.send(dp);
        //关闭资源
        ds.close();

    }
}
